<?php

/**
 * sound actions.
 *
 * @package    sfwixet
 * @subpackage sound
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class soundActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this->forward('default', 'module');
  }
  
public function executePlay(sfWebRequest $request)
  {
  	$id = $request->getParameter("id");
  	$sound = Doctrine::getTable("sound")->find($id);
  	if(is_object($sound)){
		//$this->getResponse()->setHttpHeader('Content-type', 'audio/mpeg');
		//$this->getResponse()->setContent(file_get_contents($filename));
		//header('Content-Description: File Transfer');
    header('Content-Type: application/ogg');
    header('Content-Length: ' . filesize("../sounds/".$id));
    /*header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');*/
    //header('Content-Length: ' . filesize($archivo));
    ob_clean();
    flush();
  		
    	readfile("../sounds/".$id);
  	}
    	
    return sfView::NONE;
  }
  
}
